<template>
   
  <div>
       
    <!-- 客户咨询查询 -->
       
    <VxePage
      id="0001.A129.0008"
      ref="0001.A129.0008"
      :queryForm="queryForm"
      :state-count-config="statusCountConfig"
      :list-page-config="{
        tableFixColumns: true,
        tableFixHeight: true,
        tableMode: 'radio',
        showCfgButton: true,
      }"
      @doDetail="doDetailCheck"
      @doExport="doExport"
      @doPrint="doPrint"
      @openDetailWidow="openDetailWidow"
      :handleQueryParamsFun="handleQueryParamsFun"
    >
           
      <template #buttonGroup>
               
        <bfe-button
          type="primary"
          icon="search"
          :loading="
            $refs['0001.A129.0008']
              ? $refs['0001.A129.0008'].tableLoading
              : false
          "
          @click="doSearch"
        >
                    {{ $t("stm.btn.query") }}        
        </bfe-button>
             
      </template>
           
      <template #cond_bankId="{ cfg }">
               
        <bfe-form-item
          :label="$t('stm.AIFInquiry.bankName')"
          style="width: 210px"
          prop="bankId"
          :rules="cfg.rule"
        >
                   
          <bfe-select
            v-model="queryForm.bankId"
            size="small"
            :disabled="userInfo.userAhrInstNo !== '3'"
            :placeholder="$t('stm.validateTip.pleaseSelect')"
            @change="getCertType"
            :rules="cfg.rule"
            filterable
            clearable
          >
                       
            <bfe-option
              v-for="(item, index) in bankIdObj[language]"
              :key="item.key + index"
              :label="item.value"
              :value="item.key"
            />
                     
          </bfe-select>
                 
        </bfe-form-item>
             
      </template>
           
      <template #cond_idType>
               
        <bfe-form-item
          :label="$t('stm.CIFInquiry.idTyp')"
          style="width: 210px"
          prop="idType"
        >
                   
          <bfe-select
            v-model="queryForm.idType"
            size="small"
            :placeholder="$t('stm.validateTip.pleaseSelect')"
            filterable
            clearable
          >
                       
            <bfe-option
              v-for="(item, index) in selectObj['certType'][language]"
              :key="item.key + index"
              :label="item.value"
              :value="item.key"
            />
                     
          </bfe-select>
                 
        </bfe-form-item>
             
      </template>
           
      <template #cond_custStatusParam>
               
        <bfe-form-item
          :label="$t('stm.CIFInquiry.custLcSubType')"
          style="width: 210px"
          prop="custStatusParam"
        >
                   
          <bfe-select
            v-model="queryForm.custStatusParam"
            size="small"
            :placeholder="$t('stm.validateTip.pleaseSelect')"
            filterable
            clearable
          >
                       
            <bfe-option
              v-for="(item, index) in selectObj['custStatusParam'][language]"
              :key="item.key + index"
              :label="item.value"
              :value="item.key"
            />
                     
          </bfe-select>
                 
        </bfe-form-item>
             
      </template>
         
    </VxePage>
     
  </div>
</template>

<script>
import VxePage from "@/components/vxePage/vxePage";
import mixinList from "@stm/mixins";

export default {
  components: {
    VxePage,
  },
  mixins: [mixinList],
  data() {
    return {
      queryForm: {
        bankId: "0",
      },
      statusCountConfig: {},
      bankIdObj: {
        zh_TW: [],
        en_US: [],
      },
      selectObj: {
        certType: {},
      },
      pageInfo: null,
    };
  },
  mounted() {
    if (this.userInfo.userAhrInstNo !== "3") {
      this.queryForm.bankId = this.userInfo.userAhrInstNo;
    }
    this.getBankIdObj("bankIdObj", "STM006PUBLIC0101");
    this.getCertType();
  },
  methods: {
    handleQueryParamsFun(params) {
      this.pageInfo = params.pageInfo;
    }, // 导出
    doExport() {
      if (!this.queryForm.bankId) {
        this.$message.warning(this.$t("stm.ruleMessage.bankId"));
        return false;
      }
      const { createDate, birthday } = this.queryForm;
      if (createDate && createDate.length) {
        this.queryForm.createDateStartStr = createDate[0];
        this.queryForm.createDateEndStr = createDate[1];
      } else {
        this.queryForm.createDateStartStr = "";
        this.queryForm.createDateEndStr = "";
      }
      if (birthday && birthday.length) {
        this.queryForm.birthdayStartStr = birthday[0];
        this.queryForm.birthdayEndStr = birthday[1];
      } else {
        this.queryForm.birthdayStartStr = "";
        this.queryForm.birthdayEndStr = "";
      }
      this.baseDownload(
        {
          optCode: "STM004GET20219",
          payload: {
            ...this.queryForm,
          },
        },
        this.$api["_01_STM004DOWNLOAD1200"]
      );
    }, // 打印
    doPrint() {
      if (!this.queryForm.bankId) {
        this.$message.warning(this.$t("stm.ruleMessage.bankId"));
        return false;
      }
      const { createDate, birthday } = this.queryForm;
      if (createDate && createDate.length) {
        this.queryForm.createDateStartStr = createDate[0];
        this.queryForm.createDateEndStr = createDate[1];
      } else {
        this.queryForm.createDateStartStr = "";
        this.queryForm.createDateEndStr = "";
      }
      if (birthday && birthday.length) {
        this.queryForm.birthdayStartStr = birthday[0];
        this.queryForm.birthdayEndStr = birthday[1];
      } else {
        this.queryForm.birthdayStartStr = "";
        this.queryForm.birthdayEndStr = "";
      }
      this.baseDownload(
        {
          optCode: "STM004GET20230",
          payload: {
            ...this.queryForm,
          },
          pageInfo: this.pageInfo
            ? this.pageInfo
            : {
                pageNo: 1,
                pageSize: 15,
                total: 0,
              },
        },
        this.$api["_01_STM004DOWNLOAD1200"]
      );
    },
    getCertType() {
      this.selectObj = {
        certType: {},
        custStatusParam: {},
      };
      const arr = [
        { paratype: "certType", paraname: this.queryForm.bankId || "0" },
        { paratype: "custStatusParam", paraname: this.queryForm.bankId || "0" },
      ];
      this.getSelectList(arr);
    },
    doDetailCheck(row) {
      const arr = row.rows;
      if (arr.length !== 1) {
        this.$message.warning(this.$t("stm.handleTips.selectOne"));
        return;
      }
      const { bankId, custId, idNum, idType, idTypeDesc, custType } = arr[0];
      const info = { bankId, custId, idNum, idType, idTypeDesc, custType };
      const route = {
        path: "/stm/commonInquiry/CIFDetails" + "_" + info.custId,
        name: "CIFDetails" + "_" + info.custId,
        component: () =>
          import(
            /* webpackChunkName: "layout" */ "@/views/business-o/stm/views/commonInquiry/CIFInquiry/CIFDetails.vue"
          ),
        componentUrl: "/commonInquiry/CIFInquiry/CIFDetails.vue",
        index: "0001.A129.0008",
        label: { zh_TW: "客戶詳情", en_US: "Cust Details" },
        labelVal: info.custId,
      };
      this.linkToPage(route, { ...info });
    },
    doSearch() {
      const { createDate, birthday } = this.queryForm;
      if (createDate && createDate.length) {
        this.queryForm.createDateStartStr = createDate[0];
        this.queryForm.createDateEndStr = createDate[1];
      } else {
        this.queryForm.createDateStartStr = "";
        this.queryForm.createDateEndStr = "";
      }
      if (birthday && birthday.length) {
        this.queryForm.birthdayStartStr = birthday[0];
        this.queryForm.birthdayEndStr = birthday[1];
      } else {
        this.queryForm.birthdayStartStr = "";
        this.queryForm.birthdayEndStr = "";
      }
      this.$refs["0001.A129.0008"].doSearch("pageOne");
    },
  },
};
</script>